<!--公共头部-->
{template 'aitimt/common/header'}
<style>
    body{background: #ffffff;}
    .login_box{background: #FFF;border-radius: 4px;display: block;padding: 15px;position: fixed;top:3rem;width: 90%;left:5%}
    ::-webkit-input-placeholder { /* WebKit, Blink, Edge */color: #4e4e4e;font-size: 14px;}
    ::-moz-placeholder { /* Mozilla Firefox 4 to 18 */color: #4e4e4e;font-size: 14px;}
    ::-moz-placeholder { /* Mozilla Firefox 19+ */color: #4e4e4e;font-size: 14px;}
    ::-ms-input-placeholder { /* Internet Explorer 10-11 */color: #4e4e4e;font-size: 14px;}
    .login_head h2 {font-size: 0.8rem;line-height: 16px;margin-bottom: 16px;color:#06bf04;text-align: center;font-weight: normal}
    .mui-input-row input{border:0;border-bottom: 1px solid #e4e4e4;}
    .btn_login{width:100%;height:2.2rem;line-height: 2.2rem;display: block;background-color:#f39800;font-size:15px;text-align: center;margin:1.5rem auto 0;color:#FFF; border-color: #03b401;border-radius: 15px;}
    .btn_login:hover{color:#FFF}
    .mui-input-row label {width: 25%;}
    .mui-input-row label ~ input, .mui-input-row label ~ select, .mui-input-row label ~ textarea{width: 75%;}
    .login-xieyi{width: 110%;margin-left: -18px;font-size:12px;text-align: center;margin-top: 60%;}

</style>
</head>
<body>
<div class="mui-content">
    <div class="login_box" >
        <div class="mui-input-row">
            <input type="password" id='pwd' placeholder="请设置8-32位(数字+字母)"/>
        </div>
        <a class="btn_login" id="btn_login">保存新密码</a>

    </div>

</div>
<script type="text/javascript">

    mui.init();
    document.getElementById("btn_login").addEventListener('tap', function() {
        var pwd = $.trim($("#pwd").val());
        if (pwd == '') {
            mui.toast('请输入密码');
            $('#pwd').focus();
            return false;
        }
       var sum = checkPass(pwd);
        if (sum<2){
            mui.toast('需至少8位，且包含大小写字母和数字');
            $('#pwd').focus();
            return false;
        }
        function checkPass(pass) {
            if (pass.length < 8) {
                return 0;
            }
            if (pass.length > 32) {
                return 0;
            }
            var str = 0;
            if (pass.match(/([a-z])+/)) {
                str++;
            }
            if (pass.match(/([0-9])+/)) {
                str++;
            }
            if (pass.match(/([A-Z])+/)) {
                str++;
            }
            if (pass.match(/[^a-zA-Z0-9]+/)) {
                str++;
            }
            return str;
        }
            $.post("{php echo app_url('home/index/loginpwd')}", {pwd:pwd}, function(data){
            console.log(data);
            if(data.errno == 0){
                mui.toast('设置成功');
                setTimeout(function() {
                    location.href = data.url;
                },1000);
            }else{
                mui.toast('服务器错误！');
            }
        },"json");
    });


</script>
</body>
</html>
